package com.loongtech.bi.action.advertisment;

import com.loongtech.bi.advertisment.controller.BaseAdvAction;
import com.loongtech.bi.advertisment.model.AdvWarningInputData;
import com.loongtech.bi.advertisment.service.PayUserService;
import com.loongtech.core.util.Time;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * 
 * ClassName: AdvWarnInputAction
 * 
 * @Description: 积分墙统计
 * @author liuchen
 * @date 2017-7-31 下午2:10:12
 */

@Controller
@Scope("prototype")
@RequestMapping("/market/advWarnInputMarket")
public class AdvWarnInputBiAction extends BaseAdvAction {

	private String dateRadio = "1"; // 切换的天数：1=昨天。7=近7天。15=近15天。30=近30天，0=自选时间

	private Date dateStart = new Date(Time.getBeginningOfDay(Time.currentTime() - 0)); // 自选时间：开始时间
	private Date dateEnd = new Date(Time.getBeginningOfDay(Time.currentTime() - 0)); // 自选时间：结束时间

	private List<AdvWarningInputData> warningDatas;

	private static final long serialVersionUID = 1L;

	@Resource(name = "payUserService")
	private PayUserService payUserService;

    @RequestMapping(value = "search.do", method = { RequestMethod.GET, RequestMethod.POST })
    public void search(HttpServletRequest request, HttpServletResponse response, @RequestParam String sday, @RequestParam String eday, String callback) {
        try {
            Map<String, Object> result = new HashMap<>();

            warningDatas = payUserService.getListWarningInputData(sday, eday);

            result.put("res", "0");
            result.put("warningDatas", warningDatas);

            printToJson(response, result, callback);
        } catch (Exception e) {
            e.printStackTrace();
            Map<String, Object> result = new HashMap<>();
            result.put("res", "1");
            result.put("msg", e.getMessage());
            printToJson(response, result, callback);
            return;
        }
	}

	public String getDateRadio() {
		return dateRadio;
	}

	public void setDateRadio(String dateRadio) {
		this.dateRadio = dateRadio;
	}

	public Date getDateStart() {
		return dateStart;
	}

	public void setDateStart(Date dateStart) {
		this.dateStart = dateStart;
	}

	public Date getDateEnd() {
		return dateEnd;
	}

	public void setDateEnd(Date dateEnd) {
		this.dateEnd = dateEnd;
	}

	public List<AdvWarningInputData> getWarningDatas() {
		return warningDatas;
	}

	public void setWarningDatas(List<AdvWarningInputData> warningDatas) {
		this.warningDatas = warningDatas;
	}
}
